package util;

import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class GsonUtil {
static	GsonBuilder builder=new GsonBuilder();
static{
	builder.setExclusionStrategies(new ExclusionStrategy(){
		public boolean shouldSkipClass(Class<?> arg0) {
//			 if(arg0.getName().contains("pojo")){
//				 return true;
//			 }
			return false;
		}
		 public boolean shouldSkipField(FieldAttributes arg0) {
			 //�ֶε����Ͱ�����pojo �ؼ��־Ͳ�ת��
//			 if( arg0.getDeclaredType().toString().contains("pojo.")){
//				 return true;
//			 }
			 //�ֶε����Ͱ���util ��ת��
			 if( arg0.getDeclaredType().toString().contains("util.")){
				 return true;
			 }
			return false;
		}
	});
}
	public static String toJson(Object o){
		Gson gson = builder.setDateFormat("yyyy-MM-dd").create();
		return gson.toJson(o);
	}
}
